<?php
/**
*+-----------IMBA后台管理广告位管理控制器------------+
*+-------------------------------------------------+
*@author susy.liang <liangling@ilongyuan.com.cn>
*+-------------------------------------------------+
*/
namespace Admin\Controller;

class AdsController extends BaseManageController {
	/**
	*控制操作的模型表
	*/
	protected $modelName = 'Ads';	

	/**
	*删除类型的设置 true|直接删除， false|设置数据状态
	*/	
	protected $is_del	= false;

	/**
	*跳转的Url
	*/
	protected $jumpAct	= 'Ads/index';

	/**
	*操作index的前置操作
	*---设置数据筛选条件---
	*/
	public function _before_index()
	{
		$map = array();//筛选条件
        $map['status'] = array('egt',0);
		$search = trim(I('get.name', '', 'strip_tags'));
        if($search){
            $map['name']    =   array('like', (string)$search);
        }
        $this->where = $map;

        $this->template = C('ADS_TEMPLATE');

	}

    public function push()
    {
        if (IS_POST) {
            $msg = I('msg');
            $uri = I('uri');
            $game_id = I('game_id');
            if (empty($msg) || empty($uri) || empty($game_id)) {
                $this->error('参数错误');
            }

            event('Push')->active($msg, $uri, $game_id);
            $this->success('推送完成');
        } else {
            $data['games'] = event('game')->lists([], 'id,name');

            $this->assign($data);
            $this->display();
        }
    }

}